using Chaotic.DataBase.DataAccess;
using Chaotic.DataBase.DBAccessLibrary.DBAccessLibrary;
using Chaotic.DataBase.DBAccessLibrary.Interface;
using Chaotic.DataBase.DBAccessLibrary.Model;

namespace Chaotic.DataBase.OLEDBAccess;

public class OleGrammar : DBGrammar, IGrammar, ILocalGrammar
{ 
	public OleGrammar(ConnectionModel? connect)
		: base(connect)
	{
	}

    public override string GetChTableSql => string.Empty;

    public string? IsExistChTableSql => string.Empty;


    protected override string? GetTypeFilter(FieldEntity? field, string sql)
	{
		string? typeName = field.TypeName;
		int.TryParse(field.Length, out var _);
		string? text = field.Length;
		string text2 = field.TypeName.ToUpper();
		if (text2 == "TIMESTAMP" || text2 == "DATE")
		{
			text = "";
		}
		if (!field.IsNull)
		{
			sql += " Not Null";
		}
		return string.Format(sql, field.TableName, field.Name, typeName, text);
	}

 
 
	public string GetPageingSql(string sql, decimal index, decimal count)
	{
		return sql;
	}

	public DatabaseType GetConnectionStr(out string connectStr)
	{
		connectStr = _connect.ConnectionStr;
		return DatabaseType.OleDBSupported;
	}
}
